import { ElMessage, ElNotification } from "element-plus";
import { type AxiosResponse } from "axios";
import { type DataType } from "@/types/response";
import resUtil from "./resUtil";
import ResUtil from "./resUtil";
class Notice {
  //如果不成功那么久报错
  public static errorMsg(res: AxiosResponse<any, any>){
    if(!resUtil.isSuccess(res)&&ResUtil.getMessage(res)){
      Notice.error(ResUtil.getMessage(res))
    }
  }
  public static resMessage(res: AxiosResponse<any, any>) {
    let msg = resUtil.getMessage(res);
    if (resUtil.isSuccess(res)) Notice.success(msg);
    else Notice.error(msg);
  }
  public static info(msg: string) {
    ElMessage({
      showClose: true,
      type: "success",
      grouping: true,
      plain: true,
      message: msg,
    });
  }
  public static success(msg: string) {
    ElMessage({
      showClose: true,
      type: "success",
      grouping: true,
      message: msg,
    });
  }
  public static error(msg: string) {
    ElMessage({
      showClose: true,
      type: "error",
      grouping: true,
      message: msg,
    });
  }
  public static notificationSuccess(title: string, msg: string) {
    ElNotification({
      title,
      message: msg,
      type: "success",
    });
  }
  public static notificationError(title: string, msg: string) {
    ElNotification({
      title,
      message: msg,
      type: "error",
    });
  }
  public static notificationWaring(title: string, msg: string) {
    ElNotification({
      title,
      message: msg,
      type: "warning",
    });
  }
}
export default Notice;
